package org.alps.pattern.adapter.poweradapter;

/**
 *  适配器模式
 *  电源转接头场景：
 *  * 国标：220v
 *  * 手机锂电池：5v直流
 *  * 适配：变压器，把电压降低
 * @date 2021-05-01
 * @author zkw
 */
public class PowerAdapter implements DC5 {

    private AC220 ac220;

    /**
     * 兼容原接口
     * @param ac220
     */
    public PowerAdapter(AC220 ac220) {
        this.ac220 = ac220;
    }

    /**
     * 适配：实现新接口
     * @return
     */
    @Override
    public int outputDC5V() {
        int adapterInput = ac220.outputAC220V();
        int adapterOutput = adapterInput / 44;
        System.out.println("使用PowerAdapter输入AC:" + adapterInput + "V，输出DC：" + adapterOutput + "V");
        return adapterOutput;
    }
}
